/*
 *  Copyright 2008 Mark Ashworth <javameme@gmail.com>.
 * 
 *  Licensed under the GNU General Public License v3 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 * 
 *       http://www.gnu.org/licenses/gpl-3.0.html
 * 
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *  under the License.
 */
package xperiment.metaphor.model.question;

import xperiment.metaphor.model.resource.TextResource;
import xperiment.metaphor.model.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;

/**
 * 
 * @author Mark Ashworth
 * @version 1.0.0
 */
public class Question extends DomainObject implements Persistent {
    
	@Id @GeneratedValue(strategy=GenerationType.AUTO) 
    @Column(name = "question_id", unique = true, nullable = false)
    private Long id = null;
    
	/** The default question text */
	private String text;
	/** Text resources : question */
	private List<TextResource> resources;
	/** Question is enabled */
	private boolean enabled;
	/**
	 * Default constructor
	 */
	public Question() {
		this(null, new ArrayList<TextResource>());
	}
	/**
	 * Constructs the question with the default text
	 * @param text The default text for the question
	 */
	public Question(String text) {
		this(text, new ArrayList<TextResource>());
	}
	/**
	 * Constructs the question with the text resource
	 * @param text The default text
	 * @param resource The question resource
	 */
	public Question(String text, TextResource resource) {
		this(text, Arrays.asList(new TextResource[]{resource}));
	}
	/**
	 * Constructs the question with the text resources
	 * @param text The default text
	 * @param resources The question resources
	 */
	public Question(String text, List<TextResource> resources) {
		super();
		this.resources = resources;
	}
	/**
	 * Identity
	 * @return long
	 */
	public Long getId() {
		return this.id;
	}
	
	/**
	 * Enabled
	 * @return boolean
	 */
	public boolean isEnabled() {
		return enabled;
	}
	
	/**
	 * Enabled
	 * @param enabled
	 */
	public void setEnabled(boolean enabled) {
		this.enabled = enabled;
	}

	/**
	 * The default text for the question
	 * @return String
	 */
	public String getText() {
		return text;
	}

	/**
	 * The default text for the question
	 * @param text The new value
	 */
	public void setText(String text) {
		this.text = text;
	}
	
	/**
	 * The question text resources
	 * @return List of text resources
	 */
	public List<TextResource> getResources() {
		return resources;
	}

	/**
	 * The question text resources
	 * @param resources The new resources
	 */
	public void setResources(List<TextResource> resources) {
		this.resources = resources;
	}
	
	/**
	 * Adds a text resource
	 * @param resource The resource to add
	 */
	public void add(TextResource resource) {
		this.resources.add(resource);
	}
}

